<template>
	<view>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30" v-if="user.status===1" @click="jump">
			<view class="u-m-r-10 u-m-t-40">
				<u-avatar :src="user.avatarUrl" size="140"></u-avatar>
			</view>
			<view class="u-flex-1 u-m-t-40">
				<view class="u-font-18 u-p-b-10">{{user.userName}}</view>
				<view class="u-font-14 u-tips-color">性别:{{user.gender}}</view>
			</view>
			<view class="u-m-l-10 u-p-10 u-m-t-40">
				<u-icon name="arrow-right" color="#969799" size="28"></u-icon>
			</view>
		</view>
		<view>
			<u-gap height="40" bg-color="white"></u-gap>
		</view>
		<view>
			<u-grid :col="4" border="true">
				<u-grid-item @click="toannounce">
					<u-icon name="../../../static/addad.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">发布通知</view>
				</u-grid-item>
				<u-grid-item @click="jumpMApply()">
					<u-badge type="error" :count="arrageCount" :offset="[20, 20]"></u-badge>
					<u-icon name="../../../static/form.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">通过排班</view>
				</u-grid-item>
				<u-grid-item @click="jumpAllowAppiontment()">
					<u-badge type="error" :count="appointmentCount" :offset="[20, 20]"></u-badge>
					<u-icon name="../../../static/feedback.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">通过预约</view>
				</u-grid-item>
				<u-grid-item @click="jumpMessagePage()">
					<u-icon name="/static/mes.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">评价</view>
				</u-grid-item>
			</u-grid>
			<u-grid :col="4" border="true">
				<u-grid-item @click="jumpNotice()">
					<u-badge :count="count" :offset="[20, 20]"></u-badge>
					<u-icon name="/static/notice.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">消息总览</view>
				</u-grid-item>
				<u-grid-item @click="jumpIndexNotice()">
					<u-icon name="/static/indexNotice.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">主页通知</view>
				</u-grid-item>
				<u-grid-item @click="jumpSetSwiper()">
					<u-icon name="/static/set_swiper.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">轮播图设置</view>
				</u-grid-item>
				<u-grid-item @click="jumpSetTimeOrder()">
					<u-icon name="/static/time.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">时间设置</view>
				</u-grid-item>
			</u-grid>
			<u-grid :col="4" border="true" v-if="flag">
				<u-grid-item @click="jumpModule()">
					<u-icon name="/static/work.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">模块设置</view>
				</u-grid-item>
				<u-grid-item @click="jumpCheckPerson()">
					<u-icon name="/static/check.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">查看学员信息</view>
				</u-grid-item>
				<u-grid-item @click="jumpManageBranch()">
					<u-icon name="/static/manage_branch.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">管理分校</view>
				</u-grid-item>
				<u-grid-item @click="jumpSetManagement()" >
					<u-icon name="../../../static/people.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">用户管理</view>
				</u-grid-item>
				<u-grid-item @click="jumpSettings()" v-if="flag">
					<u-icon name="/static/setting.png" :size="46"></u-icon>
					<view class="grid-text u-m-t-20">设置</view>
				</u-grid-item>
			</u-grid>

		</view>
		<view>
			<u-popup v-model="show">
				<view>系统繁忙</view>
			</u-popup>
		</view>
	</view>
</template>

<script>
	import api from "../../utils/api.js"
	export default {
		data() {
			return {
				count:'',
				appointmentCount:0,
				arrageCount:0,
				evluateCount:0,
				flag:false,
				user: {},
				pic: 'https://uviewui.com/common/logo.png',
				show: false,
				evlFlag:false,
			}
		},
		created() {
			this.requestdata()
			let user = uni.getStorageSync("user")
			if (user.roleId === "1"){
				this.flag = true
			}
			this.getthreenews()
			this.requestUnAppointmentData()
			this.requestUnAprrangeData()
			this.requestEvluateData()
		},
		methods: {
			requestEvluateData(){
				
			},
			requestUnAppointmentData(){
				let user = uni.getStorageSync("user")
				api.getUnArrageAndAppointmentList(user.branchId, 2, 2).then(res => {
					console.log("-------------------------arrange---------------------")
					console.log(res)
					this.arrageCount = res.data.length
					console.log(this.arrageCount)
				})
			},
			requestUnAprrangeData(){
				let user = uni.getStorageSync("user")
				api.getUnArrageAndAppointmentList(user.branchId, 2, 1).then(res => {
					console.log("----------------------appointment------------------")
					console.log(res)
					this.appointmentCount = res.data.length
					console.log(this.appointmentCount)
				})
			},
			getthreenews(){
				api.getunreadnews(uni.getStorageSync("user").branchId).then(res=>{
					if(res.data>0){
						this.count = res.data
					}
				})
			},
			jump() {
				wx.navigateTo({
					url: "../m_user_details/m_user_details"
				})
			},
			toannounce() {
				wx.navigateTo({
					url: "../m_announce/m_announce"
				})
			},
			requestdata() {
				api.getUserInfo(uni.getStorageSync('token')).then((res) => {
					this.user = res.data.info
					uni.setStorageSync('userVO', res.data);
				})
			},
			jumpSetManagement: function() {
				uni.navigateTo({
					url: "/pages/m_set_manager/m_set_manager",
					success: (res) => {
						console.log("成功跳转！")
					},
					fail: (res) => {
						this.show = true;
					}
				})
			},
			jumpMApply: function() {
				uni.navigateTo({
					url: '../m_judge/m_judge',
					success: (res) => {
						console.log(res)
					}
				})
			},
			jumpSettings: function() {
				uni.navigateTo({
					url: '../m_setting/m_setting',
					success: (res) => {
						console.log(res)
					}
				})
			},
			jumpMessagePage: function() {
				uni.navigateTo({
					url: '../m_message/m_message',
					success: (res) => {
						console.log(res)
					}
				})
			},
			jumpNotice: function() {
				uni.navigateTo({
					url: '../m_notice/m_notice',
					success: (res) => {
						console.log(res)
					}
				})
			},
			jumpSetTimeOrder:function(){
				uni.navigateTo({
					url:"../m_set_time/m_set_time",
					success: (res) => {
						console.log(res)
					}
				})
			},
			jumpAllowAppiontment:function(){
				uni.navigateTo({
					url:"../m_allow/m_allow",
					success: (res) => {
						console.log(res)
					}
				})
			},
			jumpModule:function(){
				uni.navigateTo({
					url:'../m_set_module/m_set_module',
					success: (res) => {
						console.log(res)
					}
				})
			},
			jumpIndexNotice:function(){
				uni.navigateTo({
					url:'../m_index_notice/m_index_notice',
					success: (res) => {
						console.log(res)
					}
				})
			},
			jumpCheckPerson:function(){
				uni.navigateTo({
					url:"../m_check/m_check",
					success:(res)=>{
						console.log(res)
					}
				})
			},
			jumpManageBranch:function(){
				uni.navigateTo({
					url:'../m_set_branch/m_set_branch',
					success: (res) => {
						console.log(res)
					}
				})
			},
			jumpSetSwiper:function(){
				uni.navigateTo({
					url:"../m_set_swiper/m_set_swiper",
					success:(res) => {
						console.log(res)
					}
				})
			}
		}
	}
</script>

<style>

</style>
